﻿@model ExcellOnServices.Models.Order

@{
    ViewBag.Title = "Details";
    Layout = "~/Areas/DashBoard/Views/Shared/_Layout.cshtml";
    decimal totalMoney = 0;
    int countDate = Model.EndDateTime.Subtract(Model.BeginDateTime).Days;
}

<div class="panel panel-primary">
    <div class="panel-heading">Order Details</div>
    <div class="panel-body">
        <p>
            @Html.LabelFor(model => model.Id, "Order ID", new { @class = "control-label col-md-2" })
            @Html.DisplayFor(model => model.Id)
        </p>
        <p>
            @Html.LabelFor(model => model.BeginDateTime, "Begin Date", new { @class = "control-label col-md-2" })
            @Html.DisplayFor(model => model.BeginDateTime)
        </p>
        <p>
            @Html.LabelFor(model => model.EndDateTime, "End Date", new { @class = "control-label col-md-2" })
            @Html.DisplayFor(model => model.EndDateTime)
        </p>
        <p>
            @Html.LabelFor(model => model.Payment, new { @class = "control-label col-md-2" })
            @switch ((int)@Model.Payment)
            {
                case 0:
                    @Html.Label("payment", "Cash", new { @class = "control-label", style = "font-weight: normal;" })
                    break;
                case 1:
                @Html.Label("payment", "Credit Card", new { @class = "control-label", style = "font-weight: normal;" })
                    break;
            }
        </p>
        <p>
            @Html.LabelFor(model => model.Status, new { @class = "control-label col-md-2" })
            @switch ((int)@Model.Status)
            {
                case 0:
                    @Html.Label("status", "Pending", new { @class = "control-label", style = "font-weight: normal;" })
                    break;
                case 1:
                @Html.Label("status", "Canceled", new { @class = "control-label", style = "font-weight: normal;" })
                    break;
                case 2:
                @Html.Label("status", "Confirmed", new { @class = "control-label", style = "font-weight: normal;" })
                    break;
                case 3:
                @Html.Label("status", "Activated", new { @class = "control-label", style = "font-weight: normal;" })
                    break;
                case 4:
                @Html.Label("status", "Expired", new { @class = "control-label", style = "font-weight: normal;" })
                    break;
            }
        </p>
        <br />

        <table class="table table-striped table-hover">
            <tr>
                <th>
                    Image
                </th>
                <th>
                    Category
                </th>
                <th>
                    Name
                </th>
                <th>
                    Service
                </th>
                <th>
                    Service Price
                </th>
            </tr>
            @foreach (var item in Model.OrderItems)
            {
                <tr>
                    <td>
                        <img src="@item.Product.ImageUrl" style="width:50px;" />
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Product.Category.Name)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Product.Name)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Service.Name)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ServicePrice)
                        @Html.Hidden("totalMoney", totalMoney = (item.ServicePrice * countDate) + totalMoney)
                    </td>
                </tr>
            }
            <tr>
                <th colspan="4">
                    Total of money
                </th>
                <td>
                    @String.Format("{0:C}", @totalMoney)
                </td>
                <td></td>
            </tr>
        </table>
    </div>
    <div class="panel-footer">
        @switch ((int)Model.Status)
        {
            case 0: //Pending
                @Html.ActionLink("Delete", "Delete", new { id = Model.Id}, new { @class = "btn btn-danger btn-sm", onclick = "return confirm('Are you sure you wish to delete this order?');" })
                break;
            case 3: //Activate
                @Html.ActionLink("Edit", "Edit", new { id = Model.Id}, new { @class = "btn btn-primary btn-sm" })
                break;
        }
        @Html.ActionLink("Back to List", "Index", null, new { @class = "btn btn-primary btn-sm" })
    </div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
